package com.railway.dao.impl;

import java.security.acl.Group;
import java.util.List;

import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import com.railway.bean.Groups;
import com.railway.dao.GroupsDao;
import com.railway.util.DBUtil;

public class GroupsDaoImpl implements GroupsDao {

	JdbcTemplate jt = new JdbcTemplate(DBUtil.getDataSource()); 
	@Override
	public List<Groups> selectGroups(int serviceGroups_id) {
		String sql = "SELECT t1.service_name,t2.service_detailed,t3.title_name FROM 12306service AS t1 \r\n" + 
				"JOIN 12306servicedetailed AS t2 \r\n" + 
				"ON t1.service_detailed_id = t2.service_detailed_id JOIN title AS t3 \r\n" + 
				"ON t3.title_id = t2.title_id WHERE t1.service_id = ?";
		return jt.query(sql, new BeanPropertyRowMapper<Groups>(Groups.class),serviceGroups_id);
	}

}
